export class Audio {
	constructor() {
		this.audio = uni.createInnerAudioContext()
		this.audio.onCanplay(() => {
			uni.hideLoading()
		});
		this.audio.onTimeUpdate(() => {
			uni.$emit('time', this.audio.currentTime)
		});
		this.audio.onPlay(() => {

		});
		this.audio.onPause(() => {});
		this.audio.onEnded(() => {
			this.audio.playbackRate = 1
			uni.$emit('playend')
		})
	}
	changePlaySudu(sudu) {
		this.audio.playbackRate = sudu
	}
	play(url) {
		if (this.audio.src == url) {
			this.audio.seek(0)
		} else {
			this.audio.src = url
		}
		this.audio.play()
	}
	end() {
		this.audio.pause()
	}
	dele() {
		this.audio.pause();
		this.audio.destroy();
		this.audio = null;
	}
}